/********************************************************************
	created:	2008/10/04
	created:	4:10:2008   14:24
	filename: 	h:\SimoneEngine\qianye\src\qylib\tuningkit\qyLogMgr.h
	author:		Xiong Jiayu
	copyright:  
	purpose:	
*********************************************************************/
#pragma once

#ifndef __QYLOGMGR_H__
#define __QYLOGMGR_H__

#include "../common/qySingleton.h"
#include "../memsys/qyString.h"
#include "../memsys/qyMap.h"
#include "qyLogger.h"
#include "qyLogHttpString.h"

/*
===========================================
enum ELog_Flag
===========================================
*/
enum ELog_Flag
{
	eLF_Normal,
	eLF_Worning,
	eLF_Error,
	eLF_Mem,
	eLF_IO
};

/*
===========================================
class qyLogMgr
===========================================
*/
class qyLogMgr : public qySingleton< qyLogMgr >
{
	typedef qyMap<qyString, qyLogger*>	LoggerList;
public:
						qyLogMgr();
						~qyLogMgr();

	void				AddLogFile( const std::string fileName );
	qyLogger *			SetLogFile( const std::string fileName );

	qyLogger *			GetLogger( void );
protected:
	void				ReleaseAllLoggers();
protected:
	LoggerList			m_loggerList;
	qyLogger			*m_pLogger;
};

#if defined( _DEBUG ) | defined( DEBUG )
#	define qyDBG_CreateLogServer					new qyLogMgr();
#	define qyDBG_ReleaseLogServer					delete qyLogMgr::GetSingletonPtr();
#	define qyDBG_AddLog( name )						qyLogMgr::GetSingleton().AddLogFile( (name) )
#	define qyDBG_SetLog( name )						qyLogMgr::GetSingleton().SetLogFile( (name) )
#	define qyDBG_LOG(msg)							qyLogMgr::GetSingleton().GetLogger()->LogMsg( (msg))
#	define qyDBG_LOG_LINE(msg,bline)				qyLogMgr::GetSingleton().GetLogger()->LogMsg( (msg), (bline) )
#	define qyDBG_LOG_STYLE(msg,bline,style)			qyLogMgr::GetSingleton().GetLogger()->LogMsg( (msg), (bline), (style) )
#else
#	define qyDBG_CreateLogServer
#	define qyDBG_ReleaseLogServer
#	define qyDBG_AddLog( name )
#	define qyDBG_SetLog( name )
#	define qyDBG_LOG(msg)	
#	define qyDBG_LOG_LINE(msg,bline)				
#	define qyDBG_LOG_STYLE(msg,bline,style)	
#endif // _DEBUG
#endif

